package com.shop2cn.iapi.sqoptrade.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class UpdateOrderDeliveryTimeCall extends YmatouBaseCall {
	
	private static String opurl = "api/seller/updateOrderDeliveryTime";

	public UpdateOrderDeliveryTimeCall() {
//		super(EnvSetup.getSystemUrl("operate2_iapi"), opurl, "POST", "JSON");
		super(EnvSetup.getSystemUrl("sqoptrade_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	// get data
	public JSONObject getData() {
		JSONObject data = null;
		try {
			data = (JSONObject) new JSONObject(getReturnData()).get("data");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return data;
	}

	// code
	public int getCode() {
		Integer code = null;
		try {
			code = new JSONObject(getReturnData()).optInt("errorCodeValue");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return code;
	}

	// bcode
	public int getBcode() {
		Integer code = null;
		try {
			code = new JSONObject(getReturnData()).optInt("bcode");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return code;
	}

	// errorMessage
	public String getMsg() {
		String msg = null;
		try {
			msg = new JSONObject(getReturnData()).optString("errorMessage");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}
	
	// success
	public Boolean getSuccess() {
		Boolean success = null;
		try {
			success = new JSONObject(getReturnData()).optBoolean("success");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return success;
	}
}
